package com.panshi.controller.article;

import com.panshi.api.ArticleApi;
import com.panshi.vo.ArticleAddVo;
import com.panshi.vo.ArticleUpdateVo;
import com.panshi.vo.ResponseVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@Slf4j
@RequestMapping("/article")
public class CompileArticleController {

    @Resource
    private ArticleApi articleApi;

    /**
     * 新增文章
     * @param articleAddVo
     * @return
     */
    @RequestMapping("/add")
    @ResponseBody
    public ResponseVO addArticle(ArticleAddVo articleAddVo){
        log.info("+++++++++++++++++++ 新增文章+++++ articleAddVo:{}",articleAddVo);
        ResponseVO vo = articleApi.addArticle(articleAddVo);
        log.info("查询出来的数据-------------------vo:{}",vo);
        return vo;
    }

    /**
     * 修改文章
     * @param articleUpdateVo
     * @return
     */
    @RequestMapping("/update")
    @ResponseBody
    public ResponseVO update(ArticleUpdateVo articleUpdateVo){
        log.info("+++++++++++++++++++ 修改文章+++++ articleUpdateVo:{}",articleUpdateVo);
        ResponseVO vo = articleApi.updateArticle(articleUpdateVo);
        log.info("查询出来的数据-------------------vo:{}",vo);
        return vo;
    }

}
